/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modele;

import java.lang.UnsupportedOperationException;

/**
 * @author Hadrien
 */
public class OrlyVal extends Order {

    override public var description = bind "{quantity} OrlyVal / {if (reduceFare) "Tarif réduit" else "Plein tarif"}";
    public var reduceFare: Boolean = false on replace { computePrice() };
    public var startStation: String = "" on replace { computePrice() };

    init {
        if (reduceFare) {
            price = if (startStation == "Antony") 3.95 else if (startStation == "Paris") 5.1 else 0.0;
        } else {
            price = if (startStation == "Antony") 7.9 else if (startStation == "Paris") 10.25 else 0.0;
        }
        name = "Orly Val ticket";
    }

    override public function deliver(): Void {
        for (i in [1..quantity]) {
            println("Print a {name} from {startStation} {if (reduceFare) "reduce fare" else "full fare"})");
        }
    }

    function computePrice() {
        if (reduceFare) {
            price = if (startStation == "Antony") 3.95 else if (startStation == "Paris") 5.1 else 0.0;
        } else {
            price = if (startStation == "Antony") 7.9 else if (startStation == "Paris") 10.25 else 0.0;
        }
    }


}
